package io.github.chutian0610.sqlparser.dialect

import io.github.chutian0610.sqlparser.token.CodePoint

class Hive : Dialect {
    override fun supportsNumericPrefix(): Boolean = true

    override fun isIdentifierPart(c: CodePoint): Boolean {
        return c.isAsciiLowercase() || c.isAsciiUppercase() || c.isAsciiDigit() || CodePoint.equalsChar(c, '$')
    }

    override fun isIdentifierStart(c: CodePoint): Boolean {
        return c.isAsciiLowercase() || c.isAsciiUppercase() || c.isAsciiDigit()
                || CodePoint.equalsChar(c, '_')
                || CodePoint.equalsChar(c, '$')
                || CodePoint.equalsChar(c, '{')
                || CodePoint.equalsChar(c, '}')
    }

    /**
     * Hive, like many SQL-based systems, uses "backticks" to enclose identifiers
     * that are reserved keywords or contain special characters, such as spaces.
     *
     * Also，Hive can be configured to support ANSI-compliant double-quoted identifiers
     * by setting the hive.support.quoted.identifiers property,
     */
    override fun isDelimitedIdentifierStart(c: CodePoint): Boolean =
        CodePoint.equalsChar(c, '"') || CodePoint.equalsChar(c, '`')

}